/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package br.com.teste;

import br.com.modelo.Cliente;
import br.com.modelo.Pedido;
import java.util.Calendar;
import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.Persistence;

/**
 *
 * @author egberto
 */
public class AdicionaPedidoCliente {
    public static void main(String args[]){
        EntityManagerFactory factory = Persistence.createEntityManagerFactory("default");
        EntityManager manager = factory.createEntityManager();
        
        manager.getTransaction().begin();
        
        Cliente c = new Cliente();
        c.setNome("Rafael jaustino");
        
        Pedido p = new Pedido();
        p.setDataPedido(Calendar.getInstance());
        p.setCliente(c);
        
        manager.persist(c);
        manager.persist(p);
        
        manager.getTransaction().commit();
        
        manager.close();
        factory.close();
        
    }
    
    
}
